package com.zxb.core.common.exception;

/**
 * @author Zxb
 */

public enum E {
	ERROR(500, "操作过程出现异常"),

	/**
	 * 验证请求，抛出的异常
	 */
	NO_TOKEN(600, "用户未登录"),
	BAD_TOKEN(601, "会话失效"),
	NO_USER(602, "用户不存在"),
	STOP_USER(603, "用户被禁用"),
	NO_AUTH(604, "用户没有权限进行操作"),
	RATE_LIMIT(605, "操作太频繁，请稍后再试"),
	NO_TENANT(606, "未找到租户信息"),
	BAD_METHOD(607, "请求方法不符合要求"),
	REPEAT_SUBMIT(608, "不允许重复提交，请稍后再试"),
	UN_SAFE_BAD_SECRET(609, "安全验证appSecret错误"),
	UN_SAFE_TIMEOUT(610, "安全验证请求超时"),
	UN_SAFE_BAD_SIGN(611, "安全验证签名错误"),
	BAD_PARAM(612,"参数转换错误"),
	NO_SAFE_TOKEN(620, "缺少安全凭证"),
	BAD_SAFE_TOKEN(621, "无效的安全凭证"),

	/**
	 * 断言抛出的异常
	 */
	VALID_NOT_NULL(700,"不能为NULL"),
	VALID_NOT_EMPTY(701,"不能为空"),
	VALID_NOT_BLANK(702,"不能为空字符串"),
	VALID_TRUE(703,"必须为真"),
	VALID_MATCH(704,"不符合格式要求"),
	VALID_IN_DATABASE(705,"在数据库中未找到"),

	/**
	 * 文件系统异常
	 */
	IO_ERROR(800,"发生io异常"),
	FILE_NOT_FIND(801,"文件未找到"),
    ;

	private Integer code;
	private String msg;

	E(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public void happen() {
		throw new BusinessException(this);
	}

	public void happen(String suffix) {
		throw new BusinessException(this, suffix);
	}
}
